package com.cskaoyan.javase.oop1._3memory;

/**
 * 三个引用的内存图，其中有两个引用指向同一个对象。
 *
 * @since 15:09
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo2 {
    public static void main(String[] args) {
        Teacher t1 = new Teacher();
        Teacher t2 = t1;

        Teacher t3 = new Teacher();

        System.out.println(t1);
        System.out.println(t2);
        System.out.println(t3);
        // true
        System.out.println(t1 == t2);
        // false
        System.out.println(t1 == t3);

        t1.salary = 10000;
        System.out.println(t2.salary);
        System.out.println(t3.salary);
    }
}

class Teacher {
    double salary = 100000;
    int age = 18;

    public void teach() {
        System.out.println("老师在上课!");
    }
}
